/*
 * XYTCustomNeighborhood.java
 *
 * Created on April 1, 2005, 8:55 AM
 */

package edu.temple.GUS.MMA.Neighborhoods;

import edu.temple.GUS.MMA.DataTypes.*;

/**
 *
 * @author jleong
 */
public class XYTCustomNeighborhood extends XYTNeighborhood{
    
    private boolean filter[][][];

    /** Creates a new instance of XYTCustomNeighborhood */
    public XYTCustomNeighborhood(int x, int y, int t, boolean filter[][][])
    {
        // Define the x, y and t extend of the neighborhood
        super(x,y,t);
        this.filter = filter;
    }

    /** Creates a new instance of XYTCustomNeighborhood */
    public XYTCustomNeighborhood(MMATimeCube filterCube)
    {
        // Define the x, y and t extend of the neighborhood
        super(filterCube.getX(),filterCube.getY(),filterCube.getT());
        
        int x = filterCube.getX();
        int y = filterCube.getY();
        int t = filterCube.getT();
        float noData = filterCube.getNoData();
        
        // Create a customed filter
        filter = new boolean[t][y][x];
        
        for (int k=0; k<t; k++)
            for (int j=0; j<=y; j++)
                for (int i=0; i<=x; i++)
                {
                    if ( filterCube.getElement(i,j,k) == noData )
                        filter[k][j][i] = false;
                    else
                        filter[k][j][i] = true;
                }
    }
    
    public boolean getFilterElement(int x, int y, int t) { return filter[t][y][x];}
}
